UnfinishedItemsManagerView = Ext.extend(Ext.Panel, {
    constructor : function(a) {
        Ext.applyIf(this, a);
        var all=this.initUIComponents();
        UnfinishedItemsManagerView.superclass.constructor.call(this, {
            id : "UnfinishedItemsManagerView",
            region : "center",
            layout : "border",
            border : false,
            iconCls : "menu-position",
            items : [all.yearGridPanel]
        });
    },
    initUIComponents : function() {
         var yearGridComponents=new creategridview({
             topbar : {
                 hidden: true,
                 topbarAdd:{
                     hidden:true
                 },
                 topbarDel:{
                     hidden:true
                 }
             },
            search : {
                items : [ ]
            },
            grid : {
                
                title : "待办任务列表",
                rowdblclick:true,
                listUrl : __ctxPath + "/bpmndemo/listUnfinishedTaskWorkflow.do",
                fields : [ "id",'name','processName',"createTime", "assignee","formKey","processInstanceId"],
                columns : [ {
                    header : "任务ID",
                    dataIndex : "id",
                    hidden :true
                },{
                    header : "流程实例Id",
                    dataIndex : "processInstanceId",
                    hidden :true
                }, {
                    header : "处理业务的FormWindow",
                    dataIndex : "formKey",
                    hidden :true
                },  {
                    header : "流程名称",
                    dataIndex : "processName",
                    hidden : false,
                    width : 70
                }, {
                    header : "当前任务名称",
                    dataIndex : "name",
                    width : 70
                }, {
                    header : "任务创建时间",
                    dataIndex : "createTime",
                    width : 100
                }, {
                    header : "当前任务审核人",
                    dataIndex : "assignee",
                    width : 40
                },{
                    header:"操作",
                    dataIndex:"id",
                    width:70,
                    renderer : function(value, cellmeta, record, rowIndex, columnIndex, store) {
                        var cfg={
                               taskId : value,
                               refreshGridId : yearGridComponents.yearGridPanel.getId(),
                               formWindow:"LeavBillAuditFormWindow",
                               processInstanceId: record.data.processInstanceId
                        }
                        var k = "";
                            k += '　<a href="javascript:void(0)" onclick=\'UnfinishedItemsManagerView.banlirenwu('
                                + JSON.stringify(cfg) + ')\'>办理任务</a>';
                            k += '　<a href="javascript:void(0)" onclick=\'UnfinishedItemsManagerView.dangqianliuchengtu('
                                + JSON.stringify(cfg) + ')\'>查看当前流程图</a>';
                        return k;
                    }
                }]
                
            }
        });
        return yearGridComponents;
    }
});
UnfinishedItemsManagerView.banlirenwu=function(config){
    Ext.Ajax.request({
        url: __ctxPath + "/bpmndemo/findInfoBeforeAuditWorkflow.do",
        params: { processInstanceId: config.processInstanceId },
        success: function(resp,thiz){
           var rsponObj= Ext.decode(resp.responseText);
           if(rsponObj.success){
               var keybusinessId=rsponObj.result;
               if(keybusinessId){
                   var cfg={
                           businessId :  keybusinessId.split(".")[1],
                               taskId :  config.taskId,
                           instanceId :  config.processInstanceId,
                           refreshGridId : config.refreshGridId
                         }
                         var c='new '+config.formWindow+'('+Ext.encode(cfg)+')';
                         eval(c).show(); 
               }
               
               //Ext.ux.Toast.msg("操作提示：","流程启动成功！")
           }else{
               //Ext.ux.Toast.msg("流程启动失败：",rsponObj.msg)
           }
        },
        failure: function(){
            Ext.ux.Toast.msg("操作提示：","请求失败！")
        }
     });
}
UnfinishedItemsManagerView.dangqianliuchengtu=function(cfg){
    Ext.Ajax.request({
        url: __ctxPath + "/bpmndemo/viewCurrentTaskCoordingWorkflow.do",
        params: { taskId: cfg.taskId },
        success: function(resp,thiz){
           var rsponObj= Ext.decode(resp.responseText);
           if(rsponObj.success){
               var r=rsponObj.result;
               var config={
               xx:r.x+5,
               yy:r.y,
               height:r.height,
               width:r.width,
               deploymentId:r.deploymentId,
               diagramResourceName:r.diagramResourceName,  
               }
               new WorkFlowCurrentTaskPngWindow(config).show();
           }else{
               
           }
        },
        failure: function(){
            Ext.ux.Toast.msg("操作提示：","请求失败！")
        }
     });
}